Skip to content

Improve warning/error message for writable violations#4738

Merged
greg-rychlewski merged 1 commit into
elixir-ecto:masterfrom
green-david:dg-improve-writable-violation-message
Jun 19, 2026
Merged

Improve warning/error message for writable violations#4738
greg-rychlewski merged 1 commit into
elixir-ecto:masterfrom
green-david:dg-improve-writable-violation-message

Conversation

@green-david

Copy link
Copy Markdown
Contributor

This PR improves the error message introduced in #4734 to hopefully improve the user experience of actually receiving this warning / error. The updated message is patterned off of the existing message you get with on_replace: :raise when trying to replace an association.

The goal of the new message is twofold:

  1. By including the schema in the message, it makes clear which actual schema module the field is defined in. If the field is a common field name like :value, :status, :archived_at, etc., it would be difficult to find out exactly which schema with said field is being violated otherwise.
  2. By including references to the :writable and :on_writable_violation options in the message itself, it gives the user a jumping off point to reference the docs directly to figure out how to address the warning / error rather than having to try to figure out where it is coming from.

Open to any other suggestions 😄

@greg-rychlewski greg-rychlewski merged commit c4bb74a into elixir-ecto:master Jun 19, 2026
8 checks passed
@greg-rychlewski

Copy link
Copy Markdown
Member

thanks again :)

@green-david green-david deleted the dg-improve-writable-violation-message branch June 19, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants